﻿using System;
using System.Web.Mvc;
using System.Linq;
using System.Web.Script.Serialization;

namespace Controllers
{
    public class DailyController : BaseController
    {
        public ActionResult GetDailyByEmpDate(int empId, DateTime logDate)
        {
            var daily = ctx.Dailies.SingleOrDefault(r => r.EmpId == empId && r.CreatDate == logDate);
            return Json(daily);
        }

        //取42天内有日志的日期
        public ActionResult GetHasDailyDates(int empId,string startDateStr)
        {
            DateTime startDate = DateTime.Parse(startDateStr);
            DateTime endData = startDate.AddDays(41);
            var list = from r in ctx.Dailies where r.EmpId == empId && r.CreatDate>=startDate && r.CreatDate<=endData orderby r.CreatDate select r.CreatDate;
            return Json(list);
        }
    }
}